package com.op.teachingliteapp.activity;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.Toast;

import com.op.teachingliteapp.R;
import com.op.teachingliteapp.fragment.teaching_material;
/*
 * 这是第二个界面的主Activity
 */
public class Main_Two extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main_two);
	
		
		if(getFragmentManager().findFragmentById(R.id.main_show)==null){
			getFragmentManager().beginTransaction().addToBackStack(null).add(R.id.main_show2,new teaching_material()).commit();
		}
		
	//返回上层界面
	findViewById(R.id.back).setOnClickListener(new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			//Toast.makeText(getApplicationContext(), "返回",Toast.LENGTH_SHORT).show();
			Intent i =new Intent(Main_Two.this,MainActivity.class);
			startActivity(i);
		}
	});
		
		
	//教学资料
	findViewById(R.id.button_data).setOnClickListener(new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			findViewById(R.id.button_data).setBackgroundResource(R.drawable.button_data1);
			findViewById(R.id.button_discussion).setBackgroundResource(R.drawable.button_discussion3);
			findViewById(R.id.button_notice).setBackgroundResource(R.drawable.button_notice3);
			getFragmentManager().beginTransaction().addToBackStack(null). replace(R.id.main_show2,new teaching_material()).commit();
			
		}
	});
	
	//课程讨论
	findViewById(R.id.button_discussion).setOnClickListener(new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			findViewById(R.id.button_data).setBackgroundResource(R.drawable.button_data3);
			findViewById(R.id.button_discussion).setBackgroundResource(R.drawable.button_discussion1);
			findViewById(R.id.button_notice).setBackgroundResource(R.drawable.button_notice3);
			Toast.makeText(getApplicationContext(), "课程讨论", Toast.LENGTH_SHORT).show();
		}
	});
	
	//课程通知
	findViewById(R.id.button_notice).setOnClickListener(new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			findViewById(R.id.button_data).setBackgroundResource(R.drawable.button_data3);//杩樺師
			findViewById(R.id.button_discussion).setBackgroundResource(R.drawable.button_discussion3);//杩樺師
			findViewById(R.id.button_notice).setBackgroundResource(R.drawable.button_notice1);//鎸変笅
			Toast.makeText(getApplicationContext(), "课程通知", Toast.LENGTH_SHORT).show();
		}
	});	
		
		
	//投影
	findViewById(R.id.send_show).setOnTouchListener(new OnTouchListener() {
		@SuppressLint("ClickableViewAccessibility")
		@Override
		public boolean onTouch(View v, MotionEvent event) {
			if(event.getAction()==MotionEvent.ACTION_DOWN){
				//保留有用，不要删
			}
			if(event.getAction()==MotionEvent.ACTION_UP){
				Toast.makeText(getApplicationContext(), "教学投影", Toast.LENGTH_SHORT).show();
			}
			return false;
		}
	});
	//查询
	findViewById(R.id.search).setOnTouchListener(new OnTouchListener() {
		@SuppressLint("ClickableViewAccessibility")
		@Override
		public boolean onTouch(View v, MotionEvent event) {
			if(event.getAction()==MotionEvent.ACTION_DOWN){
				//保留有用，不要删
			}
			if(event.getAction()==MotionEvent.ACTION_UP){
				Toast.makeText(getApplicationContext(), "查询", Toast.LENGTH_SHORT).show();
			}
			return false;
		}
	});
	//更多
	findViewById(R.id.more).setOnTouchListener(new OnTouchListener() {
		@SuppressLint("ClickableViewAccessibility")
		@Override
		public boolean onTouch(View v, MotionEvent event) {
			if(event.getAction()==MotionEvent.ACTION_DOWN){
				//保留有用，不要删
			}
			if(event.getAction()==MotionEvent.ACTION_UP){
				Toast.makeText(getApplicationContext(), "更多", Toast.LENGTH_SHORT).show();
			}
			return false;
		}
	});
	
	
	}
	/*锁定虚拟返回键
	 * (non-Javadoc)
	 * @see android.app.Activity#onKeyDown(int, android.view.KeyEvent)
	 */
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		
		return false;
	}
}
